//
//  RightTableViewController.m
//  DeliciousFoodBible
//
//  Created by lanou3g on 15/7/19.
//  Copyright (c) 2015年 孙连爽. All rights reserved.
//

#import "RightTableViewController.h"
#import "RightTableViewCell.h"
#import "LoginViewController.h"
@interface RightTableViewController ()

@property (nonatomic,retain) NSArray *array;

@end

@implementation RightTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
    
    self.title = @"我的";
    
    
    [self.tableView registerNib:[UINib nibWithNibName:@"RightTableViewCell" bundle:nil] forCellReuseIdentifier:@"reuseIdentifier" ];
    [self.tableView registerNib:[UINib nibWithNibName:@"MessageTableViewCell" bundle:nil] forCellReuseIdentifier:@"reuseIdentifier1"];
    
    
    self.array = [[NSArray alloc] initWithObjects:@"我的收藏",@"设置",@"清除缓存", nil];
    
    
    

}

//-(void) loginButton{
//    LoginViewController *login = [[LoginViewController alloc] init];
//    [self.navigationController pushViewController:login animated:YES];
//}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    // Return the number of rows in the section.
    return self.array.count +1 ;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.row == 0) {
        return 153;
    }else{
       return 60;
    }
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
   
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *identifier = @"reuseIdentifier";
    static NSString *identifier1 = @"reuseIdentifier1";
    
    RightTableViewCell *cell = [[RightTableViewCell alloc] init];
    if (indexPath.row == 0) {
        cell = [tableView  dequeueReusableCellWithIdentifier:identifier];
        cell.loginButton.layer.cornerRadius = 30;
        cell.loginButton.layer.borderWidth = 1;
        cell.loginButton.layer.borderColor = [UIColor clearColor].CGColor;
        cell.loginButton.clipsToBounds = TRUE;
        
        [cell.loginButton  addTarget:self action:@selector(loginButton:) forControlEvents:UIControlEventTouchUpInside];
    }else{
        cell = [tableView dequeueReusableCellWithIdentifier:identifier1];
        
        cell.textLabel.text = [self.array objectAtIndex:indexPath.row - 1];
    }
    
    // Configure the cell...
    
    return cell;
}

-(void) loginButton:(UIButton *)button{
 
    LoginViewController *login = [[LoginViewController alloc] init];
    [self.navigationController pushViewController:login animated:YES];
}

/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
